package do

import (
	compb "gitee.com/micro-services/protocol/common"
	"micro.user.action.server/models"
	"micro.user.action.server/utils"
	"time"
)

func ConvertWxUserInfo(user *models.VsWxUser) *compb.WxUserInfo {
	var userName, phone string
	userName, _ = utils.Decrypt(user.WxUserName)
	if user.Phone != "" {
		phone, _ = utils.Decrypt(user.Phone)
	}

	return &compb.WxUserInfo{
		WxUserID:     user.WxUserId,
		WxUserName:   userName,
		WxAvatarIcon: user.WxAvatarIcon,
		Gender:       user.Gender,
		Phone:        phone,
		RegistryTime: time.Unix(user.CreatedTime, 0).Format("2006-01-02 15:04:05"),
		UpdateTime:   time.Unix(user.UpdatedTime, 0).Format("2006-01-02 15:04:05"),
	}
}
